<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增专家消息')" />
    <th:block th:include="include :: select2-css" />
    <!--文件上传-->
    <link th:href="@{/layui-v2.5.4/css/layui.css}" rel="stylesheet"/>
    <style type="text/css">
        .uploader-list {
            margin-left: -15px;
        }

        .uploader-list .info {
            position: relative;
            margin-top: -25px;
            background-color: black;
            color: white;
            filter: alpha(Opacity=80);
            -moz-opacity: 0.5;
            opacity: 0.5;
            width: 100px;
            height: 25px;
            text-align: center;
            display: none;
        }

        .uploader-list .handle {
            position: relative;
            background-color: black;
            color: white;
            filter: alpha(Opacity=80);
            -moz-opacity: 0.5;
            opacity: 0.5;
            width: 100px;
            text-align: right;
            height: 18px;
            margin-bottom: -18px;
            display: none;
        }

        .uploader-list .handle i {
            margin-right: 5px;
        }

        .uploader-list .handle i:hover {
            cursor: pointer;
        }

        .uploader-list .file-iteme {
            margin: 12px 0 0 15px;
            padding: 1px;
            float: left;
        }
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-add">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">会员ID：</label>
                    <div class="col-sm-8">
                        <select name="memberId" id="memberId" class="form-control" th:with="memberInfoList=${@memberInfo.selectMemberInfoListForqd()}">
                            <option th:each="memberinfo : ${memberInfoList}" th:text="${memberinfo.nikeName}"
                                    th:value="${memberinfo.memberId}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label"><span style="color: red; ">*</span>主图上传：</label>
                    <div class="col-sm-8">

                        <div class="layui-upload">
                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 100%">
                                预览图：
                                <div class="layui-upload-list uploader-list" style="overflow: auto;" id="uploader-list">

                                </div>
                            </blockquote>
                            <button type="button" class="layui-btn" id="test2">主图上传</button>
                        </div>
                        <input id="personalPhoto" name="personalPhoto"  type="hidden">

                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">真实姓名：</label>
                    <div class="col-sm-8">
                        <input name="realName" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <!--<div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">手机号：</label>
                    <div class="col-sm-8">
                        <input name="phone" class="form-control" type="text">
                    </div>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">邮箱：</label>
                    <div class="col-sm-8">
                        <input name="email" class="form-control" type="text">
                    </div>
                </div>
            </div>-->
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">所在地编码：</label>
                    <div class="col-sm-8">
                        <input name="areaCode" class="form-control" type="text" required>
                    </div>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">擅长领域编码：</label>
                    <div class="col-sm-8">
                        <select name="regionCode" id="regionCode" class="form-control select2-multiple" multiple th:with="cropDictList=${@cropdict.selectCropDictByPartant(0)}">
                            <option th:each="cropdicta : ${cropDictList}" th:text="${cropdicta.cropName}"
                                    th:value="${cropdicta.cropId}"></option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">擅长专业作物编码：</label>
                    <div class="col-sm-8">
                        <select name="cropCode" id="cropCode" class="form-control select2-multiple" multiple th:with="cropDictList=${@cropdict.selectCropDictByPartant(1)}">
                            <option th:each="cropdicta : ${cropDictList}" th:text="${cropdicta.cropName}"
                                    th:value="${cropdicta.cropId}"></option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">个人简介：</label>
                    <div class="col-sm-8">
                        <textarea name="personalProfile" class="form-control" type="text"> </textarea>
                    </div>
                </div>
            </div>
            <!--<div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">审核状态：</label>
                    <div class="col-sm-8">
                        <select name="verifyStatus" id="verifyStatus" class="form-control">
                            <option value="1">审核通过</option>
                            <option value="0">审核失败</option>
                        </select>
                    </div>
                </div>
            </div>-->
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">专家注册时所属系统名称：</label>
                    <div class="col-sm-8">
                        <input name="sysName" class="form-control" type="text">
                    </div>
                </div>
            </div>

        </form>
    </div>

    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>

    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script type="text/javascript" th:inline="javascript">

        var ctx  = [[${#request.getContextPath()}]];

        var prefix = ctx + "/agriculture/info"
        $("#form-info-add").validate({
            focusCleanup: true
        });

        var questionImages = "";

        var  upurl=ctx + "/oss/upload";
        //上传图片
        layui.use('upload', function () {
            var upload = layui.upload;
            upload.render({
                elem: '#test2'
                , url: upurl
                , multiple: true
                , accept: "images"
                , acceptMime: "image/*"
                , before: function (obj) {
                    layer.msg('图片上传中...', {
                        icon: 16,
                        shade: 0.01,
                        time: 0
                    })
                }
                , done: function (res) {
                    layer.close(layer.msg());//关闭上传提示窗口
                    questionImages = res.data;
                    $("#personalPhoto").val(questionImages);
                    //上传完毕
                    $('#uploader-list').html(
                        '<div id="" class="file-iteme">' +
                        '<div class="handle"><i class="layui-icon layui-icon-delete"></i></div>' +
                        '<img style="width: 100px;height: 100px;" src=' + res.data + '>' +
                        '</div>'
                    );
                }
            });
        })

        $(document).on("mouseenter mouseleave", ".file-iteme", function (event) {
            if (event.type === "mouseenter") {
                //鼠标悬浮
                $(this).children(".info").fadeIn("fast");
                $(this).children(".handle").fadeIn("fast");
            } else if (event.type === "mouseleave") {
                //鼠标离开
                $(this).children(".info").hide();
                $(this).children(".handle").hide();
            }
        });

        // 删除图片
        $(document).on("click", ".file-iteme .handle", function (event) {
            $(this).parent().remove();
            questionImages="";
            $("#mainImg").val(questionImages);
        });



        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-info-add').serialize());
            }
        }
    </script>
</body>
</html>